package com.codepoem.designpattern.simplefactory

/**
 * 运算工厂 简单工厂类
 */
class OperationFactory() {
    companion object {
        fun createOperation(operate: String): Operation {
            var oper: Operation
            when (operate) {
                "+" -> oper = OperationAdd()
                "-" -> oper = OperationSub()
                "*" -> oper = OperationMul()
                "/" -> oper = OperationDiv()
                else -> oper = OperationAdd()
            }
            return oper
        }
    }
}